home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / dflat2.zip / REPAINT.C < prev    next >
Text File  |  1991-04-19  |  5KB  |  131 lines

  1. /* ------- display a window's border ----- */
  2. void RepaintBorder(WINDOW wnd, RECT *rcc)
  3. {
  4.     int y;
  5.     int lin, side, ne, nw, se, sw;
  6.     RECT rc, clrc;
  7.  
  8.     if (!TestAttribute(wnd, HASBORDER))
  9.         return;
  10.     if (rcc == NULL)    {
  11.         rc = SetRect(0, 0, WindowWidth(wnd)-1,
  12.                 WindowHeight(wnd)-1);
  13.         if (TestAttribute(wnd, SHADOW))    {
  14.             rc.rt++;
  15.             rc.bt++;
  16.         }
  17.     }
  18.     else
  19.         rc = *rcc;
  20.     clrc = rc;
  21.     /* -------- adjust the client rectangle ------- */
  22.     if (RectLeft(rc) == 0)
  23.         --clrc.rt;
  24.     else
  25.         --clrc.lf;
  26.     if (RectTop(rc) == 0)
  27.         --clrc.bt;
  28.     else
  29.         --clrc.tp;
  30.     RectRight(clrc) = min(RectRight(clrc), WindowWidth(wnd)-3);
  31.     RectBottom(clrc) =
  32.                      min(RectBottom(clrc), WindowHeight(wnd)-3);
  33.     if (wnd == inFocus)    {
  34.         lin  = FOCUS_LINE;
  35.         side = FOCUS_SIDE;
  36.         ne   = FOCUS_NE;
  37.         nw   = FOCUS_NW;
  38.         se   = FOCUS_SE;
  39.         sw   = FOCUS_SW;
  40.     }
  41.     else    {
  42.         lin  = LINE;
  43.         side = SIDE;
  44.         ne   = NE;
  45.         nw   = NW;
  46.         se   = SE;
  47.         sw   = SW;
  48.     }
  49.     line[WindowWidth(wnd)] = '\0';
  50.     /* ---------- window title ------------ */
  51.     if (RectTop(rc) == 0)
  52.         if (RectLeft(rc) < WindowWidth(wnd))
  53.             if (TestAttribute(wnd, TITLEBAR))
  54.                 DisplayTitle(wnd, clrc);
  55.     foreground = FrameForeground(wnd);
  56.     background = FrameBackground(wnd);
  57.     /* -------- top frame corners --------- */
  58.     if (RectTop(rc) == 0)    {
  59.         if (RectLeft(rc) == 0)
  60.             PutWindowChar(wnd, -1, -1, nw);
  61.         if (RectLeft(rc) < RectRight(rc))    {
  62.             if (RectRight(rc) >= WindowWidth(wnd)-1)
  63.                 PutWindowChar(wnd, WindowWidth(wnd)-2, -1, ne);
  64.  
  65.             if (TestAttribute(wnd, TITLEBAR) == 0)    {
  66.                 /* ----------- top line ------------- */
  67.                 memset(line,lin,WindowWidth(wnd)-1);
  68.                 line[RectRight(clrc)+1] = '\0';
  69.                 if (strlen(line+RectLeft(clrc)) > 1 ||
  70.                                TestAttribute(wnd, SHADOW) == 0)
  71.                     writeline(wnd, line+RectLeft(clrc),
  72.                             RectLeft(clrc), -1, FALSE);
  73.             }
  74.         }
  75.     }
  76.     /* ----------- window body ------------ */
  77.     for (y = 0; y < ClientHeight(wnd); y++)    {
  78.         int ch;
  79.         if (y >= RectTop(clrc) && y <= RectBottom(clrc))    {
  80.             if (RectLeft(rc) == 0)
  81.                 PutWindowChar(wnd, -1, y, side);
  82.             if (RectLeft(rc) < RectRight(rc))    {
  83.                 if (RectRight(rc) >= ClientWidth(wnd))    {
  84.                     if (TestAttribute(wnd, VSCROLLBAR))
  85.                         ch = (    y == 0 ? UPSCROLLBOX      :
  86.                                   y == WindowHeight(wnd)-3  ?
  87.                                        DOWNSCROLLBOX        :
  88.                                   y == wnd->VScrollBox      ?
  89.                                        SCROLLBOXCHAR        :
  90.                                        SCROLLBARCHAR );
  91.                     else
  92.                         ch = side;
  93.                     PutWindowChar(wnd, WindowWidth(wnd)-2,y,ch);
  94.                 }
  95.             }
  96.             if (RectRight(rc) == WindowWidth(wnd))
  97.                 shadow_char(wnd, y);
  98.         }
  99.     }
  100.     if (RectTop(rc) < RectBottom(rc) &&
  101.             RectBottom(rc) >= WindowHeight(wnd)-1)    {
  102.         /* -------- bottom frame corners ---------- */
  103.         if (RectLeft(rc) == 0)
  104.             PutWindowChar(wnd, -1, WindowHeight(wnd)-2, sw);
  105.         if (RectRight(rc) >= WindowWidth(wnd)-1)
  106.             PutWindowChar(wnd, WindowWidth(wnd)-2,
  107.                 WindowHeight(wnd)-2, se);
  108.         /* ----------- bottom line ------------- */
  109.         memset(line,lin,WindowWidth(wnd)-1);
  110.         if (TestAttribute(wnd, HSCROLLBAR))    {
  111.             line[0] = LEFTSCROLLBOX;
  112.             line[WindowWidth(wnd)-3] = RIGHTSCROLLBOX;
  113.             memset(line+1, SCROLLBARCHAR, WindowWidth(wnd)-4);
  114.             line[wnd->HScrollBox] = SCROLLBOXCHAR;
  115.         }
  116.         line[RectRight(clrc)+1] = '\0';
  117.         if (strlen(line+RectLeft(clrc)) > 1 ||
  118.                         TestAttribute(wnd, SHADOW) == 0)
  119.             writeline(wnd,
  120.                 line+RectLeft(clrc),
  121.                 RectLeft(clrc),
  122.                 WindowHeight(wnd)-2,
  123.                 FALSE);
  124.         if (RectRight(rc) == WindowWidth(wnd))
  125.             shadow_char(wnd, WindowHeight(wnd)-2);
  126.     }
  127.     if (RectBottom(rc) == WindowHeight(wnd))
  128.         /* ---------- bottom shadow ------------- */
  129.         shadowline(wnd, clrc);
  130. }
  131.